package com.wzy.mybatisplus.handel;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 描述  :
 * 创建人:    Wzy
 * 创建时间: 2020-06-02  21:50
 */
@Component
public class MyMethodDateHandel implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
//        this.fillStrategy(metaObject, "createTime", LocalDateTime.now());
//        this.fillStrategy(metaObject, "updateTime", LocalDateTime.now());
        this.setFieldValByName("createTime", new Date(), metaObject);
        this.setFieldValByName("updateTime", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // this.fillStrategy(metaObject, "updateTime", LocalDateTime.now());
        this.setFieldValByName("updateTime", new Date(), metaObject);

    }
}
